package com.iuie.ns.datum.vo;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.iuie.ns.frame.json.serializer.FileSizeSerializer;

/**
 * @author lj
 *
 */
@Table(name="NS_FILE")
@Entity
public class FileInfoVO {
	
	@Id
	private Long fileId;
	
	private String fileName;
	
	private String originalName;
	
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date uploadTime;
	
	private int downloadCount;
	
	private long fileSize;
	
	@Column(name="file_type", nullable=false)
	private String fileType;
	
	@JoinColumn(name="fileTag",referencedColumnName="tagId")
	@ManyToOne(fetch=FetchType.EAGER)
	private FileTagVO fileTag;
	
	public Long getFileId() {
		return fileId;
	}
	public void setFileId(Long fileId) {
		this.fileId = fileId;
	}
	public void setUploadTime(Date uploadTime) {
		this.uploadTime = uploadTime;
	}
	public Date getUploadTime() {
		return uploadTime;
	}
	public String getFileName() {
		return fileName;
	}
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}
	public String getOriginalName() {
		return originalName;
	}
	public void setOriginalName(String originalName) {
		this.originalName = originalName;
	}
	public int getDownloadCount() {
		return downloadCount;
	}
	public void setDownloadCount(int downloadCount) {
		this.downloadCount = downloadCount;
	}
	@JsonSerialize(using=FileSizeSerializer.class)
	public long getFileSize() {
		return fileSize;
	}
	public void setFileSize(long fileSize) {
		this.fileSize = fileSize;
	}
	public String getFileType() {
		return fileType;
	}
	public void setFileType(String fileType) {
		this.fileType = fileType;
	}
	public FileTagVO getFileTag() {
		return fileTag;
	}
	public void setFileTag(FileTagVO fileTag) {
		this.fileTag = fileTag;
	}
	@Override
	public String toString() {
		return "FileInfoVO [fileId=" + fileId + ", fileName=" + fileName
				+ ", originalName=" + originalName + ", uploadTime="
				+ uploadTime + ", downloadCount=" + downloadCount
				+ ", fileSize=" + fileSize + "]";
	}

}
